using UnityEngine;

namespace LFramework
{
    public class UIWindow : UIBase
    {
        private Canvas m_Canvas;

        protected override void OnAwake()
        {
            base.OnAwake();
            if (m_Canvas == null)
                m_Canvas = gameObject.GetComponent<Canvas>();
            if (m_Canvas == null)
                m_Canvas = gameObject.AddComponent<Canvas>();
        }

        public void SetCanvas(string sortLayer, int sortOrder)
        {
            m_Canvas.sortingLayerName = sortLayer;
            SetCanvasOrder(sortOrder);
        }

        public void SetCanvasOrder(int sortOrder)
        {
            m_Canvas.overrideSorting = true;
            m_Canvas.sortingOrder = sortOrder;
        }
    }
}
